import { Module } from '@nestjs/common';
import { ConfigModule } from '@nestjs/config';
import { TypeOrmModule } from '@nestjs/typeorm';
import { AppController } from './app.controller';
import { AppService } from './app.service';
import { User } from './users/users.entity';
import { Feed } from './feeds/feed.entity';
import { Comment } from './comments/comment.entity';
import { Like } from './matches/likes.entity';
import { AuthModule } from './auth/auth.module';
import { UsersModule } from './users/users.module';
import { MatchesModule } from './matches/matches.module';
import { ChatModule } from './chat/chat.module';
import { FeedsModule } from './feeds/feeds.module';
import { CommentsModule } from './comments/comments.module';
import { LikesModule } from './likes/likes.module';
import { VipPackage } from './vip/vip-packages.entity';
import { UserVip } from './vip/user-vip.entity';
import { DiamondTransaction } from './vip/diamond-transaction.entity';
import { VipModule } from './vip/vip.module';
import { PaypalModule } from './paypal/paypal.module';
import { PaymentMethodsModule } from './payment-methods/payment-methods.module';

@Module({
  imports: [
    ConfigModule.forRoot({ isGlobal: true }),
    TypeOrmModule.forRoot({
      type: 'postgres',
      host: process.env.DB_HOST || '43.162.111.101',
      port: parseInt(process.env.DB_PORT || '5432', 10),
      username: process.env.DB_USERNAME || 'myuser',
      password: process.env.DB_PASSWORD || '123456',
      database: process.env.DB_NAME || 'dating_app',
      entities: [
        User,
        Feed,
        Comment,
        Like,
        VipPackage,
        UserVip,
        DiamondTransaction,
      ],
      synchronize: true,
      logging: false,
    }),
    AuthModule,
    UsersModule,
    MatchesModule,
    ChatModule,
    FeedsModule,
    CommentsModule,
    LikesModule,
    VipModule,
    PaypalModule,
    PaymentMethodsModule,
  ],
  controllers: [AppController],
  providers: [AppService],
})
export class AppModule {}
